<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>prencar: D:/Workspace/Arduino/prencar/CubeApproach.h Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  <td id="projectlogo"><img alt="Logo" src="prencar.png"/></td>
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">prencar
   &#160;<span id="projectnumber">1</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.8.0 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('_cube_approach_8h.html','');
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">D:/Workspace/Arduino/prencar/CubeApproach.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="_cube_approach_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#ifndef CubeApproach_h</span>
<a name="l00002"></a>00002 <span class="preprocessor"></span><span class="preprocessor">#define CubeApproach_h</span>
<a name="l00003"></a>00003 <span class="preprocessor"></span>
<a name="l00004"></a>00004 <span class="preprocessor">#include &quot;Arduino.h&quot;</span>
<a name="l00005"></a>00005 <span class="preprocessor">#include &quot;<a class="code" href="_line_follow_8h.html">LineFollow.h</a>&quot;</span>
<a name="l00006"></a>00006 <span class="preprocessor">#include &quot;<a class="code" href="_communication_8h.html">Communication.h</a>&quot;</span>
<a name="l00007"></a>00007 <span class="preprocessor">#include &quot;<a class="code" href="_extended_move_8h.html">ExtendedMove.h</a>&quot;</span>
<a name="l00008"></a>00008 
<a name="l00009"></a><a class="code" href="struct_cube_detection.html">00009</a> <span class="keyword">struct </span><a class="code" href="struct_cube_detection.html">CubeDetection</a>{
<a name="l00010"></a><a class="code" href="struct_cube_detection.html#a3d4467976c600d4752ceb51dfd84b7e3">00010</a>   <span class="keywordtype">int</span> <a class="code" href="struct_cube_detection.html#a3d4467976c600d4752ceb51dfd84b7e3">leftBottom</a>;
<a name="l00011"></a><a class="code" href="struct_cube_detection.html#a9c7f9d19aa3c950b1d7873b965016e77">00011</a>   <span class="keywordtype">int</span> <a class="code" href="struct_cube_detection.html#a9c7f9d19aa3c950b1d7873b965016e77">leftTop</a>;
<a name="l00012"></a><a class="code" href="struct_cube_detection.html#a1ee12e3851183c6dce9777c1767c7527">00012</a>   <span class="keywordtype">int</span> <a class="code" href="struct_cube_detection.html#a1ee12e3851183c6dce9777c1767c7527">rightBottom</a>;
<a name="l00013"></a><a class="code" href="struct_cube_detection.html#a588f97b6e820b6dc1614ae67717f8206">00013</a>   <span class="keywordtype">int</span> <a class="code" href="struct_cube_detection.html#a588f97b6e820b6dc1614ae67717f8206">rightTop</a>;
<a name="l00014"></a><a class="code" href="struct_cube_detection.html#ab04af3b4a2e12f918532d92513f3f0dd">00014</a>   <span class="keywordtype">boolean</span> <a class="code" href="struct_cube_detection.html#ab04af3b4a2e12f918532d92513f3f0dd" title="Set to true if the car has turned right after this detection.">turnedRight</a>; 
<a name="l00015"></a><a class="code" href="struct_cube_detection.html#a76e665b130c62b29bd22af9f93525ce5">00015</a>   <span class="keywordtype">boolean</span> <a class="code" href="struct_cube_detection.html#a76e665b130c62b29bd22af9f93525ce5" title="Set to true if the car has turned left after this detection.">turnedLeft</a>; 
<a name="l00016"></a><a class="code" href="struct_cube_detection.html#a39d38b7af04517aac94a41958e12f656">00016</a>   <span class="keywordtype">boolean</span> <a class="code" href="struct_cube_detection.html#a39d38b7af04517aac94a41958e12f656" title="Set to true if the cube has been detected with both bottom sensors at this detection.">cubeIsCentered</a>; 
<a name="l00017"></a>00017 };
<a name="l00018"></a>00018 
<a name="l00019"></a><a class="code" href="class_cube_approach.html">00019</a> <span class="keyword">class </span><a class="code" href="class_cube_approach.html">CubeApproach</a>
<a name="l00020"></a>00020 {
<a name="l00021"></a>00021 <span class="keyword">private</span>:
<a name="l00022"></a><a class="code" href="class_cube_approach.html#a0e1bfa9a8ab15c7762e4af35b4605003">00022</a>   <span class="keyword">static</span> <span class="keywordtype">int</span> <span class="keyword">const</span> <a class="code" href="class_cube_approach.html#a0e1bfa9a8ab15c7762e4af35b4605003" title="Defines, how many cube detections can be recorded.">_MAXRECORDABLECUBEDETECTIONS</a> = 20; 
<a name="l00023"></a>00023 
<a name="l00024"></a><a class="code" href="class_cube_approach.html#ae99890596905ad65ee8a36a072a151cd">00024</a>   <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <a class="code" href="class_cube_approach.html#ae99890596905ad65ee8a36a072a151cd" title="Holds the timestamp of the time when the last cube approach check was done.">_timeLastCubeApproachCheck</a>; 
<a name="l00025"></a>00025 
<a name="l00026"></a><a class="code" href="class_cube_approach.html#a1b9e5a99d916ad25e8cb522e9786afe7">00026</a>   <a class="code" href="class_communication.html">Communication</a>* <a class="code" href="class_cube_approach.html#a1b9e5a99d916ad25e8cb522e9786afe7" title="The reference to the serial communication class.">_com</a>; 
<a name="l00027"></a><a class="code" href="class_cube_approach.html#a91fd46dd8a9d594c3d6e516406bc4440">00027</a>   <a class="code" href="class_move.html">Move</a>* <a class="code" href="class_cube_approach.html#a91fd46dd8a9d594c3d6e516406bc4440" title="The reference to the move class to control the motors.">_move</a>; 
<a name="l00028"></a><a class="code" href="class_cube_approach.html#a69026de7ba3ae39f7298469faf69759e">00028</a>   <a class="code" href="class_configuration.html">Configuration</a>* <a class="code" href="class_cube_approach.html#a69026de7ba3ae39f7298469faf69759e" title="The reference to the configuration class.">_conf</a>; 
<a name="l00029"></a><a class="code" href="class_cube_approach.html#a4e47fc77ece35197d5c1e2dda55334be">00029</a>   <a class="code" href="class_extended_move.html" title="Allows to define extended car control instuctions.">ExtendedMove</a>* <a class="code" href="class_cube_approach.html#a4e47fc77ece35197d5c1e2dda55334be" title="The reference to the extended move class.">_extMove</a>; 
<a name="l00030"></a>00030   
<a name="l00031"></a><a class="code" href="class_cube_approach.html#a2d3ac039bdca41b375557b0f0270e20d">00031</a>   <a class="code" href="class_line_follow.html">LineFollow</a> <a class="code" href="class_cube_approach.html#a2d3ac039bdca41b375557b0f0270e20d" title="LineFollow instance for the cube approach.">_lineFollow</a>; 
<a name="l00032"></a>00032   
<a name="l00040"></a><a class="code" href="class_cube_approach.html#a3831bd3f8a43dcdb1ca3c1ba185f43c4">00040</a>   <span class="keywordtype">int</span> <a class="code" href="class_cube_approach.html#a3831bd3f8a43dcdb1ca3c1ba185f43c4" title="The id of the ext move command that is responsible for stopping the car after the cube has been detec...">_stopCarExtMoveCommandId</a>;
<a name="l00041"></a><a class="code" href="class_cube_approach.html#aae0fa8f88f1ea1c01e8528d7798a7db2">00041</a>   <span class="keywordtype">boolean</span> <a class="code" href="class_cube_approach.html#aae0fa8f88f1ea1c01e8528d7798a7db2" title="True as long as &quot;stop car&quot; has not yet been performed.">_stopCarNotYetDone</a>; 
<a name="l00042"></a>00042 
<a name="l00043"></a>00043   <span class="keywordtype">void</span> <a class="code" href="class_cube_approach.html#a9a1321d9d53edf885345d9d4f3b2c765">readBottomSensors</a>(<span class="keywordtype">int</span>* resultArray);
<a name="l00044"></a>00044   <span class="keywordtype">void</span> <a class="code" href="class_cube_approach.html#a1e002f33dc385e017d2b38120e8ce580">readTopSensors</a>(<span class="keywordtype">int</span>* resultArray);
<a name="l00045"></a>00045   <a class="code" href="struct_cube_detection.html">CubeDetection</a>* <a class="code" href="class_cube_approach.html#a2e637df1eece269b680fe9313798c241">tryToDetectCube</a>();
<a name="l00046"></a>00046   <span class="keywordtype">void</span> <a class="code" href="class_cube_approach.html#a7d68e4fab2b3f7590b21aef387855633">turn</a>(<span class="keywordtype">int</span> direction);
<a name="l00047"></a>00047 <span class="keyword">public</span>:
<a name="l00048"></a><a class="code" href="class_cube_approach.html#aeac3597ee8adcaf33fbf1a523de7c8e9">00048</a>   <a class="code" href="struct_cube_detection.html">CubeDetection</a> <a class="code" href="class_cube_approach.html#aeac3597ee8adcaf33fbf1a523de7c8e9">cubeDetections</a>[<a class="code" href="class_cube_approach.html#a0e1bfa9a8ab15c7762e4af35b4605003" title="Defines, how many cube detections can be recorded.">_MAXRECORDABLECUBEDETECTIONS</a>];
<a name="l00049"></a><a class="code" href="class_cube_approach.html#a6c44784cf83ba56f87895bb5c841e7df">00049</a>   <span class="keywordtype">int</span> <a class="code" href="class_cube_approach.html#a6c44784cf83ba56f87895bb5c841e7df" title="Counter that is increased each time the cube is detected by either the left or the right sensor...">amountOfCubeDetections</a>; 
<a name="l00050"></a>00050   
<a name="l00051"></a>00051   <a class="code" href="class_cube_approach.html#aa02cb409570970adeb89e13c12678254">CubeApproach</a>();
<a name="l00052"></a>00052   <span class="keywordtype">void</span> <a class="code" href="class_cube_approach.html#ac49270ba8b7c5bb6e60ffefc31175fc2">begin</a>();
<a name="l00053"></a>00053   <span class="keywordtype">void</span> <a class="code" href="class_cube_approach.html#ac36a5c38b1108d4cd77172062e1795be">doJob</a>(<span class="keywordtype">boolean</span> followLine);
<a name="l00054"></a>00054   <span class="keywordtype">void</span> <a class="code" href="class_cube_approach.html#ad221b0dcd79878c1ab47f1ab2a0076f2">startIt</a>();
<a name="l00055"></a>00055 };
<a name="l00056"></a>00056 <span class="preprocessor">#endif</span>
<a name="l00057"></a>00057 <span class="preprocessor"></span>
<a name="l00058"></a>00058 
<a name="l00059"></a>00059 
<a name="l00060"></a>00060 
<a name="l00061"></a>00061 
<a name="l00062"></a>00062 
<a name="l00063"></a>00063 
<a name="l00064"></a>00064 
<a name="l00065"></a>00065 
<a name="l00066"></a>00066 
<a name="l00067"></a>00067 
</pre></div></div><!-- contents -->
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="_cube_approach_8h.html">CubeApproach.h</a>      </li>

    <li class="footer">Generated on Thu Jun 7 2012 20:47:42 for prencar by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.0 </li>
   </ul>
 </div>


</body>
</html>
